package cn.wolfcode.p2p.base.service.impl;

import cn.wolfcode.p2p.base.mapper.SystemDictionaryMapper;
import cn.wolfcode.p2p.base.service.ISystemDictionaryService;

import cn.wolfcode.p2p.base.domain.SystemDictionary;

import java.util.List;

import cn.wolfcode.base.QueryObject;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class SystemDictionaryServiceImpl implements ISystemDictionaryService {
    @Autowired
    private SystemDictionaryMapper systemDictionaryMapper;


    @Override
    @Transactional(readOnly = true)
    public PageInfo<SystemDictionary> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<SystemDictionary> list = systemDictionaryMapper.selectList(qo);
        return new PageInfo<SystemDictionary>(list);
    }

    @Override
    public void saveOrUpdate(SystemDictionary entity) {
        if (entity.getId() != null) {
            systemDictionaryMapper.updateById(entity);
        } else {
            systemDictionaryMapper.insert(entity);
        }
    }

    @Override
    public List<?> listAll() {
        return systemDictionaryMapper.selectAll();
    }
}
